//
//  UIBarButtonItem+Extension.swift
//  WeiboX
//
//  Created by admin on 01/12/2016.
//  Copyright © 2016 iOS_Objective-C. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
	
	convenience init(title: String, imgName: String? = nil, target: Any?, action: Selector) {
		self.init()
		
		let btn = UIButton()
		btn.addTarget(target, action: action, for: .touchUpInside)
		
		btn.setTitle(title, for: .normal)
		btn.setTitleColor(UIColor.black, for: .normal)
		btn.setTitleColor(UIColor.orange, for: .highlighted)
		
		btn.titleLabel?.font = UIFont.systemFont(ofSize: 14)
		
		if imgName != nil {
			btn.setImage(UIImage(named: imgName!), for: .normal)
		}
		
		btn.sizeToFit()
		
		self.customView = btn
	}
}
